﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="SaleOrderRequest.ascx.cs" Inherits="Admin_Components_OrderRequest_SaleOrderRequest" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>

<telerik:RadScriptManager ID="ScriptManager2" runat="server" EnableTheming="True">
</telerik:RadScriptManager>

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <telerik:radwindowmanager id="RadWindowManager" runat="server" visiblestatusbar="false" >
            <Windows>
                <telerik:RadWindow ID="RadWindow1" Modal="true"  runat="server"
                    Behaviors="Close" OnClientClose="OnClientClose">
                </telerik:RadWindow>
            </Windows>
        </telerik:radwindowmanager>
        
       <%-- <telerik:radformdecorator id="QsfFromDecorator" runat="server" decoratedcontrols="All"
            enableroundedcorners="false" />--%>
        <telerik:RadTabStrip ID="TabStrip1" runat="server" EnableDragToReorder="true" Skin="Vista" MultiPageID="RadMultiPag1" SelectedIndex="1">
            <Tabs>
                <telerik:RadTab Text="THÔNG TIN CHUNG" Selected="True">
                </telerik:RadTab>
                <telerik:RadTab Text="THÔNG TIN KHÁCH HÀNG">
                </telerik:RadTab>
                <telerik:RadTab Text="THÔNG TIN QUÀ TẶNG">
                </telerik:RadTab>
                 <telerik:RadTab Text="THÔNG TIN GIAO HÀNG">
                </telerik:RadTab>
            </Tabs>
        </telerik:RadTabStrip>
       
        <telerik:RadMultiPage ID="RadMultiPag1" runat="server" SelectedIndex="0">
            <!--Tab thông tin chung -->
            <telerik:RadPageView ID="RadPageView1" runat="server" Height="130px" Style="overflow: hidden">
                 <fieldset class="form" id="fsGeneral">
                  <br />
                <div class="form-horizontal wrapper-center clearfix">
                <!--Block bên trái -->
                 <div class="form-group col-md-6">
                  <!--Dòng -->
                    <div class="form-group">
                        <label class="col-md-3 control-label">
                            Tình trạng</label>
                        <div class="col-md-8">
                            <telerik:RadTextBox ID="txtSaleOrderStatus" CssClass="col-imp-8 inputForm" Width="70px" runat="server" readonly="true" />
                        </div>
                    </div>
                  <!--End Dòng -->
                     <!--Dòng -->
                    <div class="form-group">
                        <label class="col-md-3 control-label">
                            Mã đơn đặt hàng</label>
                        <div class="col-md-8">
                            <telerik:RadTextBox ID="txtSaleOrderCode" CssClass="col-imp-8 inputForm" Width="70px" runat="server" readonly="true" />
                        </div>
                    </div>
                  <!--End Dòng -->
                <!--Dòng -->
                <div class="form-group">
                    <label class="col-md-3 control-label">Khách hàng <span style="color:red;">(*)</span></label>
                    <div class="col-md-8">
                        <telerik:RadTextBox ID="txtCustomerCode" CssClass="col-imp-3 inputForm" Style="width:50px;display:none;" runat="server" />
                   
                        <telerik:RadTextBox ID="txtCustomerName" CssClass="col-imp-8 inputForm" Style="width:50px" Readonly="true"  runat="server" EmptyMessage="Chọn khách hàng ở Tab Thông tin khách hàng"/>
                        
                        <asp:Button ID="btnSearch" CssClass="btn btn-xs btn-primary" runat="server" Text="Tìm" OnClick="btnSearch_Click" Visible="false" />
                        <asp:RequiredFieldValidator  ID="RequiredtxtCustomerCode" runat="server" ControlToValidate="txtCustomerName" ValidationGroup="g1"
                           ErrorMessage=""></asp:RequiredFieldValidator>
                     </div>
                </div>
                
                
                </div>
                 <!--End Block bên trái -->
                 <!--Block bên phải -->
                <div class="form-group col-md-6">
                    <div class="form-group">
                        <label class="col-md-3 control-label">Cửa hàng <span style="color:red;">(*)</span></label>
                        <div class="col-md-8">
                           <telerik:RadComboBox ID="cboShop" runat="server" CssClass="col-imp-8" />
                            <asp:RequiredFieldValidator  ID="RequiredFieldValidator1" runat="server" ControlToValidate="cboShop" ValidationGroup="g2"
                           ErrorMessage="" InitialValue="---Chọn---"></asp:RequiredFieldValidator>
                         </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label">Người tạo</label>
                        <div class="col-md-8">
                            <telerik:RadTextBox ID="txtEmployeeBillName" CssClass="col-imp-8 inputForm"  runat="server" enabled="false"/>
                         </div>
                    </div>
                    <!--End Dòng -->
                <div class="form-group">
                <label class="col-md-3 control-label">Xuất hóa đơn</label>
                <div class="col-md-8">
                    <telerik:RadComboBox ID="cboIsReceiptBill" runat="server" CssClass="col-imp-3" OnSelectedIndexChanged="cboIsReceiptBill_SelectedIndexChanged" AutoPostBack="true">
                    </telerik:RadComboBox>
                     <telerik:RadComboBox ID="cboVAT"  runat="server" CssClass="col-imp-3">
                        <Items>   
                        <telerik:RadComboBoxItem runat="server" Text="10 %" Value="0.1" />   
                        </Items>
                    </telerik:RadComboBox>
                </div>
                </div>
                <!--Dòng -->
                </div>
                 <!--End Block bên phải -->
            </div>
            </fieldset>
            </telerik:RadPageView>
            <!--End Tab thông tin chung -->
             <!-- thông tin khách hàng -->
            <telerik:RadPageView ID="RadPageView4" runat="server"  Height="280px" Style="overflow: hidden">                
                    <fieldset class="form" id="Fieldset1">
                          <br />
            <div class="form-horizontal wrapper-center clearfix">
                <div class="row col-md-12">
                 <!--Block bên trái -->
                 <div class="form-group col-md-6">
                      <!--Dòng -->
                    <div class="form-group">
                        <label class="col-md-3 control-label">
                            Mã khách hàng</label>
                        <div class="col-md-3">
                            <telerik:RadTextBox ID="txtCustomerCodeNew" CssClass="col-imp-12 required"  runat="server"   />
                        </div>
                        <label class="col-md-2 control-label">Điện thoại <span style="color:red;">(*)</span></label>
                        <div class="col-md-4">
                            <telerik:RadTextBox ID="txtPhoneNumber" CssClass="col-imp-8 required"  runat="server"   />
                            <asp:RequiredFieldValidator  ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtPhoneNumber" ValidationGroup="g5"
                           ErrorMessage="" ></asp:RequiredFieldValidator>
                        </div>
                    </div>
                  <!--End Dòng -->
                    
                  <!--End Dòng -->
                     <!--Dòng -->
                    <div class="form-group">
                        <label class="col-md-3 control-label">
                            Tên khách hàng <span style="color:red;">(*)</span></label>
                        <div class="col-md-5">
                            <telerik:RadTextBox ID="txtCustomerNameNew" CssClass="col-md-6 required"  runat="server"   />
                             <asp:RequiredFieldValidator  ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtCustomerNameNew" ValidationGroup="g5"
                           ErrorMessage="" ></asp:RequiredFieldValidator>
                        </div>
                        <asp:Button ID="btnCusSave" CssClass="btn btn-sm btn-primary" runat="server" Text="Lưu" OnClick="btnCusSave_Click" ValidationGroup="g5" OnClientClick="fnOnUpdateValidators('g5');"/>
                        <asp:Button ID="btnCusSearch" CssClass="btn btn-sm btn-primary" runat="server" Text="Tìm kiếm" OnClick="btnCusSearch_Click"/>
                    </div>
                   
                 </div>
                <!--End Block bên trái -->
                <!--Block bên phải -->
                 <div class="form-group col-md-6">
                      <!--Dòng -->
                    <div class="form-group">
                        <label class="col-md-3 control-label">
                           Địa chỉ <span style="color:red;">(*)</span></label>
                        <div class="col-md-9">
                            <telerik:radtextbox ID="txtAddress" CssClass="col-md-6 inputForm"  runat="server"/>
                              <asp:RequiredFieldValidator  ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtAddress" ValidationGroup="g5"
                           ErrorMessage="" ></asp:RequiredFieldValidator>
                        </div>
                    </div>
                  <!--End Dòng -->
                     <div class="form-group">
                        <label class="col-md-3 control-label">Tỉnh/Thành <span style="color:red;">(*)</span></label>
                        <div class="col-md-3">
                           <telerik:RadComboBox ID="cboProvince" runat="server" CssClass="col-imp-12 required" OnSelectedIndexChanged="cboProvince_SelectedIndexChanged" AutoPostBack="true" />
                            <asp:RequiredFieldValidator  ID="RequiredFieldValidator5" runat="server" ControlToValidate="cboProvince" ValidationGroup="g5"
                           ErrorMessage="" InitialValue="---Chọn---"></asp:RequiredFieldValidator>
                         </div>
                         <label class="col-md-3 control-label">Quận/Huyện <span style="color:red;">(*)</span></label>
                        <div class="col-md-3">
                           <telerik:RadComboBox ID="cboDistrict" runat="server" CssClass="col-imp-12 required" />
                              <asp:RequiredFieldValidator  ID="RequiredFieldValidator6" runat="server" ControlToValidate="cboDistrict" ValidationGroup="g5"
                           ErrorMessage="" InitialValue="--Chọn--"></asp:RequiredFieldValidator>
                         </div>
                    </div>
                    
                  <!--End Dòng -->
                 </div>
                <!--End Block bên phải -->
            </div>
             <!--Action-->
           
            </div>
             <div class="row">
                <telerik:RadGrid ID="gv" runat="server" AutoGenerateColumns="False" CellSpacing="0"
                    AllowMultiRowSelection="True" GridLines="None" HeaderStyle-HorizontalAlign="Center"
                    HeaderStyle-BorderStyle="None" CssClass="table table-bordered" AllowPaging="true"
                    PageSize="50" AllowCustomPaging="true" OnNeedDataSource="gv_NeedDataSource" Height = "130px">
                    <MasterTableView AllowPaging="True" PageSize="50" EditMode="InPlace" ShowHeader="true"
                        AutoGenerateColumns="False" NoMasterRecordsText="Không có dữ liệu.">
                        <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                        </RowIndicatorColumn>
                        <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                        </ExpandCollapseColumn>
                        <Columns>
                   <telerik:GridTemplateColumn HeaderText="STT" HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center" 
                        HeaderStyle-Width="50px">
                        <ItemTemplate>
                            <%# Eval("RowID") %></ItemTemplate>
                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                    </telerik:GridTemplateColumn>
                    
                    <telerik:GridTemplateColumn SortExpression="CustomerCode" HeaderText="Mã khách hàng"  UniqueName="CustomerCode">
                    <ItemTemplate>
                      <asp:LinkButton  ID="lnkCustomerCode" runat="server" Text='<%# Eval("CustomerCode") %>' style="cursor:pointer;text-decoration:underline;" 
                        OnClick="lnkCustomerCode_Click"></asp:LinkButton>
                    </ItemTemplate>
                    <HeaderStyle HorizontalAlign="Left" Width="70px" />
                    <ItemStyle HorizontalAlign="Left" Width="70px" />
                    </telerik:GridTemplateColumn>
                     <telerik:GridBoundColumn DataField="CustomerName" HeaderStyle-HorizontalAlign="Center"
                        ItemStyle-HorizontalAlign="Left" FilterControlAltText="Filter Remark column"
                        HeaderText="Tên khách hàng" UniqueName="CustomerName">
                        <HeaderStyle HorizontalAlign="Left" Width="150px"></HeaderStyle>
                        <ItemStyle HorizontalAlign="Left"></ItemStyle>
                    </telerik:GridBoundColumn>
                     <telerik:GridBoundColumn DataField="Address" HeaderStyle-HorizontalAlign="Center"
                    ItemStyle-HorizontalAlign="Left" FilterControlAltText="Filter Remark column"
                    HeaderText="Địa chỉ" UniqueName="Address">
                    <HeaderStyle HorizontalAlign="Left" Width="200px"></HeaderStyle>
                    <ItemStyle HorizontalAlign="Left"></ItemStyle>
                    </telerik:GridBoundColumn>
                     <telerik:GridBoundColumn DataField="District" HeaderStyle-HorizontalAlign="Center"
                    ItemStyle-HorizontalAlign="Left" FilterControlAltText="Filter Remark column"
                    HeaderText="Quận/Huyện" UniqueName="District">
                    <HeaderStyle HorizontalAlign="Left" Width="100px"></HeaderStyle>
                    <ItemStyle HorizontalAlign="Left"></ItemStyle>
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Province" HeaderStyle-HorizontalAlign="Center"
                    ItemStyle-HorizontalAlign="Left" FilterControlAltText="Filter Remark column"
                    HeaderText="Tỉnh/Thành" UniqueName="Province">
                    <HeaderStyle HorizontalAlign="Left" Width="100px"></HeaderStyle>
                    <ItemStyle HorizontalAlign="Left"></ItemStyle>
                    </telerik:GridBoundColumn>
                     <telerik:GridBoundColumn DataField="PhoneNumber" HeaderStyle-HorizontalAlign="Center"
                    ItemStyle-HorizontalAlign="Left" FilterControlAltText="Filter Remark column"
                    HeaderText="Điện thoại" UniqueName="PhoneNumber">
                    <HeaderStyle HorizontalAlign="Left" Width="100px"></HeaderStyle>
                    <ItemStyle HorizontalAlign="Left"></ItemStyle>
                    </telerik:GridBoundColumn>
                    
                    <telerik:GridBoundColumn DataField="AccumulateAmount" HeaderStyle-HorizontalAlign="Center" DataFormatString="{0:###,###}"
                    ItemStyle-HorizontalAlign="Center" FilterControlAltText="Filter Remark column"
                    HeaderText="Tổng tiền tích lũy" UniqueName="AccumulateAmount">
                    <HeaderStyle HorizontalAlign="Center" Width="100px"></HeaderStyle>
                    <ItemStyle HorizontalAlign="Center"></ItemStyle>
                    </telerik:GridBoundColumn>
                      <telerik:GridBoundColumn DataField="ConvertedAmount" HeaderStyle-HorizontalAlign="Center" DataFormatString="{0:###,###}"
                    ItemStyle-HorizontalAlign="Center" FilterControlAltText="Filter Remark column"
                    HeaderText="Tổng tiền đã quy đổi" UniqueName="ConvertedAmount">
                    <HeaderStyle HorizontalAlign="Center" Width="100px"></HeaderStyle>
                    <ItemStyle HorizontalAlign="Center"></ItemStyle>
                    </telerik:GridBoundColumn>
                     <telerik:GridBoundColumn DataField="RemainAmount" HeaderStyle-HorizontalAlign="Center" DataFormatString="{0:###,###}"
                    ItemStyle-HorizontalAlign="Center" FilterControlAltText="Filter Remark column"
                    HeaderText="Tổng tiền tích lũy còn lại" UniqueName="RemainAmount">
                    <HeaderStyle HorizontalAlign="Center" Width="100px"></HeaderStyle>
                    <ItemStyle HorizontalAlign="Center"></ItemStyle>
                    </telerik:GridBoundColumn>
                </Columns>
                <EditFormSettings>
                    <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                    </EditColumn>
                </EditFormSettings>
                </MasterTableView>
                <ClientSettings>
                <Selecting AllowRowSelect="true" /></ClientSettings>
                <ClientSettings>
                <Scrolling AllowScroll="true" UseStaticHeaders="True" SaveScrollPosition="True"></Scrolling>
                </ClientSettings>
                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                    <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
                </HeaderContextMenu>
                </telerik:RadGrid>
            </div>
            </fieldset>
            </telerik:RadPageView>
            <!-- End thông tin khách hàng -->

             <!--Thông tin quà tăng-->
                <telerik:RadPageView ID="RadPageView3" runat="server"  Style="overflow: hidden">                
                    <fieldset class="form" id="fsPromotion">
                          <br />
                        
                        <div class="row" style="margin-left:15px;">
                            <telerik:radgrid id="gvPromotion" runat="server" cellspacing="0" cssclass=" table table-bordered"
                                gridlines="None" autogeneratecolumns="False" headerstyle-horizontalalign="Center"
                                allowmultirowselection="True" headerstyle-borderstyle="None" Style="width:70%;" >
                                <MasterTableView ShowHeader="true"  NoMasterRecordsText="Không có dữ liệu." ShowGroupFooter="true" EditMode="InPlace">
                                <Columns>
                                    <telerik:GridTemplateColumn HeaderText="STT" HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center">
                                        <ItemTemplate>
                                            <%# Container.ItemIndex + 1 %></ItemTemplate>
                                        <HeaderStyle Width="50px" />
                                        <ItemStyle HorizontalAlign="Center" />
                                    </telerik:GridTemplateColumn>
                                     <telerik:GridTemplateColumn  HeaderText="Hình minh họa">
                                        <ItemTemplate>
                                                <asp:Image runnat="server" ID="img" ImageUrl='<%# Eval("Image") %>' ></asp:Image>
                                        </ItemTemplate>
                                        <HeaderStyle HorizontalAlign="Left" Width="100px"  />
                                        <ItemStyle HorizontalAlign="Left" Width="100px" />
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridBoundColumn  ReadOnly="true" UniqueName="ProductID" DataField="ProductID" Display="false" ></telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn  ReadOnly="true" UniqueName="PromotionID" DataField="PromotionID" Display="false" ></telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn  ReadOnly="true" UniqueName="PromotionDetailID" DataField="PromotionDetailID" Display="false" >
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn  ReadOnly="true" UniqueName="Weight" DataField="Weight" Display="false">
                                       
                                    </telerik:GridBoundColumn>
                                     <telerik:GridBoundColumn  ReadOnly="true" HeaderText="Tên sản phẩm" UniqueName="ProductName" DataField="ProductName">
                                        <HeaderStyle HorizontalAlign="Center" />
                                        <ItemStyle HorizontalAlign="Left" Font-Bold="true"/>
                                    </telerik:GridBoundColumn>
                                     <telerik:GridTemplateColumn SortExpression="PromotionQuantitySelect" HeaderText="Loại quà tặng"
                                        UniqueName="Weight" DataField="Weight">
                                        <ItemTemplate>
                                            <asp:Label runat="server" ID="lblPromotionPack" Text='<%# Eval("Weight") %>'></asp:Label>
                                            <asp:Label runat="server" ID="Label1" Text=" (Kg)"></asp:Label>
                                        </ItemTemplate>
                                        <HeaderStyle HorizontalAlign="Right" Width="120px" />
                                        <ItemStyle HorizontalAlign="Center" Width="120px" />
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridBoundColumn  ReadOnly="true" HeaderText="Số lượng KM chưa chọn"  UniqueName="PromotionQuantity" DataField="PromotionQuantity">
                                        <HeaderStyle HorizontalAlign="Center" />
                                        <ItemStyle HorizontalAlign="Center" />
                                    </telerik:GridBoundColumn>
                                    <telerik:GridTemplateColumn SortExpression="PromotionQuantitySelect" HeaderText="Số lượng KM đã chọn"
                                        UniqueName="PromotionQuantitySelect" DataField="PromotionQuantitySelect">
                                        <ItemTemplate>
                                            <telerik:RadNumericTextBox ID="txtQuantitySelect" runat="server" AutoPostBack="true"  Text ='<%# Eval("PromotionQuantitySelect") %>'
                                                NumberFormat-DecimalDigits="0" MinValue="0" CssClass="col-imp-7 inputForm" OnTextChanged ="RadInput_TextChanged"/>
                                        </ItemTemplate>
                                        <HeaderStyle HorizontalAlign="Right" Width="140px" />
                                        <ItemStyle HorizontalAlign="Right" Width="140px" />
                                    </telerik:GridTemplateColumn>
                                    
                                </Columns>
                                </MasterTableView>
                            </telerik:radgrid>
                        </div>
                    </fieldset>
                </telerik:RadPageView>
            <!--End Thông tin quà tăng-->
           
             <!--Thong tin giao hang -->
            <telerik:RadPageView ID="RadPageView2" runat="server" Height="130px" Style="overflow: hidden">                
         
                <fieldset class="form" id="fsDelivery">
                     <br />
                     <div class="form-horizontal wrapper-center clearfix">
                         <!--Block bên trái -->
                         <div class="form-group col-md-6">
                             <!--Dòng -->
                            <div class="form-group">
                                <label class="col-md-2 control-label">
                                   Người nhận</label>
                                <div class="col-md-8">
                                    <telerik:RadTextBox ID="txtReceiptPerson" CssClass="col-imp-8 inputForm"  runat="server"/>
                                     <asp:RequiredFieldValidator  ID="RequiredtxtReceiptPerson" runat="server" ControlToValidate="txtReceiptPerson" ValidationGroup="g4"
                                    ErrorMessage=""></asp:RequiredFieldValidator>
                                </div>
                            </div>
                          <!--End Dòng -->
                          <!--Dòng -->
                            <div class="form-group">
                                <label class="col-md-2 control-label">
                                   Điện thoại</label>
                                <div class="col-md-8">
                                    <telerik:RadTextBox ID="txtReceiptPhoneNumer" CssClass="col-imp-8 inputForm"  runat="server"/>
                                     <asp:RequiredFieldValidator  ID="RequiredtxtReceiptPhoneNumer2" runat="server" ControlToValidate="txtReceiptPhoneNumer" ValidationGroup="g4"
                                    ErrorMessage=""></asp:RequiredFieldValidator>
                                </div>
                            </div>
                          <!--End Dòng -->
                        </div>
                        <!--End Block bên trái -->
                        <!--Block bên phải -->
                        <div class="form-group col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label">
                                  Địa chỉ</label>
                                <div class="col-md-8">
                                    <telerik:RadTextBox ID="txtReceiptAdress" CssClass="col-imp-10 inputForm"  runat="server"/>
                                    <asp:RequiredFieldValidator  ID="RequiredtxtReceiptAdress" runat="server" ControlToValidate="txtReceiptAdress" ValidationGroup="g4"
                                    ErrorMessage=""></asp:RequiredFieldValidator>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-md-3 control-label">
                                  Thời gian nhận </label>
                                <div class="col-md-8">

                                <telerik:RadDateTimePicker ID="dtpReceiptDate" cssclass="col-imp-8" enabled="true" runat="server">
                                    <Calendar ID="Calendar1" runat="server" EnableKeyboardNavigation="true" ViewSelectorText="x" Skin="Hay" UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False">
                                    </Calendar>
                                    <DateInput ToolTip="Thời gian nhận hàng" Enabled="False" style="width:200px" DisplayDateFormat="dd/MM/yyyy HH:mm" DateFormat="dd/MM/yyyy HH:mm"></DateInput>

                                </telerik:RadDateTimePicker>
                                     <asp:RequiredFieldValidator  ID="RequireddtpReceiptDate" runat="server" ControlToValidate="dtpReceiptDate" ValidationGroup="g4"
                                    ErrorMessage=""></asp:RequiredFieldValidator>
                                </div>
                            </div>
                        </div>
                     </div>
                </fieldset>
            </telerik:RadPageView>
             <!--End Thong tin giao hang -->
             </telerik:RadMultiPage>
            
            <!--Action-->
            <div class="set-btns text-center">
                <asp:Button ID="btnSave" CssClass="btn btn-sm btn-primary" runat="server" Text="Lưu" OnClick="btnSave_Click" OnClientClick="return Validate();"/>
                <asp:Button ID="btnCancel" runat="server" CssClass="btn btn-sm btn-warning" 
                    Text="Hủy" onclick="btnCancel_Click" OnClientClick="return ConfirmOnDelete('Bạn chắc chắn muốn hủy?')"/>
                <asp:Button ID="btnReset" runat="server" CssClass="btn btn-sm btn-primary" Text="Tạo mới" OnClick="btnReset_Click"/>
            </div>
            <!--End Action -->
            <div class="form-group text-left">
                <telerik:RadComboBox ID="cboProduct" runat="server" CssClass="col-imp-4" EmptyMessage="Nhập mã sản phẩm hoặc tên sản phẩm" filter="Contains"></telerik:RadComboBox>
                 <telerik:RadNumericTextBox ID="txtWeight" runat="server" CssClass="col-imp-1 inputForm" EmptyMessage="Trọng lượng (kg)" ></telerik:RadNumericTextBox>
                <asp:Button ID="btnAddProduct" CssClass="btn btn-sm btn-primary" runat="server" Text="Thêm" OnClick="btnAdd_Click" ValidationGroup="g3"  OnClientClick="fnOnUpdateValidators('g3');"/>
            </div>
            <div>
            <asp:RequiredFieldValidator  ID="RequiredcboProduct" runat="server" ControlToValidate="cboProduct" ValidationGroup="g3"
             ErrorMessage=""></asp:RequiredFieldValidator>
           
            <asp:RequiredFieldValidator  ID="RequiredtxtWeight" runat="server" ControlToValidate="txtWeight" ValidationGroup="g3"
             ErrorMessage=""></asp:RequiredFieldValidator>
            </div>
            <!--Grid data-->
            <div class="row">
            <telerik:radgrid id="gvData" runat="server" cellspacing="0" cssclass=" table table-bordered"
                gridlines="None" autogeneratecolumns="False" headerstyle-horizontalalign="Center" OnItemCommand="grvData_ItemCommand"
                allowmultirowselection="True" headerstyle-borderstyle="None">
                <MasterTableView ShowHeader="true" NoMasterRecordsText="Không có dữ liệu." ShowGroupFooter="true" EditMode="InPlace">
                <Columns>
                    <telerik:GridTemplateColumn HeaderText="STT" HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <%# Container.ItemIndex + 1 %></ItemTemplate>
                        <HeaderStyle Width="50px" />
                        <ItemStyle HorizontalAlign="Center" Width="50px"/>
                    </telerik:GridTemplateColumn>
                     <telerik:GridBoundColumn  HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"
                                 UniqueName="ProductID" DataField="ProductID" Display="false">
                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                    </telerik:GridBoundColumn>

                     <telerik:GridBoundColumn  DataField="ProductName" UniqueName="ProductName"  ReadOnly="true" HeaderText="Sản phẩm">
                        <HeaderStyle HorizontalAlign="Left" Width="150px"/>
                        <ItemStyle HorizontalAlign="Left" Font-Bold ="true" Width="150px"/>
                    </telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn HeaderText="Tích điểm">
                            <ItemTemplate>
                                    <%# Eval("IsPoint").ToString() == "1" ? "Có": "Không"  %>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="100px" />
                            <ItemStyle HorizontalAlign="Center" Width="100px" />
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn HeaderText="Khuyến mãi">
                            <ItemTemplate>
                                    <%# Eval("IsPromotion").ToString() == "1" ? "Có": "Không"  %>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="100px" />
                            <ItemStyle HorizontalAlign="Center" Width="100px" />
                    </telerik:GridTemplateColumn>
                    <telerik:GridBoundColumn  DataField="Price" UniqueName="Price" ReadOnly="true" HeaderText="Đơn giá">
                        <HeaderStyle HorizontalAlign="Center"  Width="100px"/>
                        <ItemStyle HorizontalAlign="Center"  Width="100px"/>
                    </telerik:GridBoundColumn>
                     <telerik:GridBoundColumn  DataField="Weight" UniqueName="Weight" ReadOnly="true" Display="false">
                    </telerik:GridBoundColumn>
                     <telerik:GridBoundColumn  DataField="IsPoint" UniqueName="IsPoint" ReadOnly="true"  Display="false" />
                     
                    <telerik:GridTemplateColumn HeaderText="Trọng lượng (kg)" UniqueName="Weight" DataField="Weight">
                            <ItemTemplate>
                                <span class="total" id="span1" runat="server">
                                    <%# String.Format("{0:#,#.##}", float.Parse(Eval("Weight").ToString() == "" ? "0" : Eval("Weight").ToString()))%>
                                </span><span class="Weight-hide" style="display: none">
                                    <%# Eval("Weight")==null ? "": Eval("Weight").ToString()  %>
                                </span>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="180px" />
                            <ItemStyle HorizontalAlign="Center" Width="180px" />
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn HeaderText="Thành tiền" UniqueName="Total" DataField="Total">
                            <ItemTemplate>
                                <span class="total" id="spanTotal" runat="server">
                                    <%# String.Format("{0:#,#.##}", float.Parse(Eval("Total").ToString() == "" ? "0" : Eval("Total").ToString()))%>
                                </span><span class="total-hide" style="display: none">
                                    <%# Eval("Total")==null ? "": Eval("Total").ToString()  %>
                                </span>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="180px" />
                            <ItemStyle HorizontalAlign="Center" Width="180px" Font-Bold ="true"/>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn HeaderText="Xóa" Visible=true HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <asp:Button ID="lnkEditDel" CssClass="btnX" CommandArgument='<%# Eval("ProductID") %>'
                                OnClientClick="return ConfirmOnDelete('Bạn chắc chắn muốn xóa?')" CommandName="EditDelItem"
                                runat="server"></asp:Button>
                        </ItemTemplate>
                        <HeaderStyle Width="30px"/>
                            <ItemStyle HorizontalAlign="Center" />
                    </telerik:GridTemplateColumn>
                </Columns>
                </MasterTableView>
            </telerik:radgrid>
        </div>

         <div id="sumTotal" runat="server" class="sum-total" style="width: 310px; float: right; font-weight: bold;font-size:13pt;"></div>
         <div style="clear:both"></div>
         <div id="sumTotalTax" runat="server" class="sum-total" style="width: 310px; float: right; font-weight: bold;font-size:13pt;"></div>
         <div style="clear:both"></div>
         <div id="divDiscount" runat="server" class="sum-total" style="width: 310px; float: right; font-weight: bold;font-size:13pt;"></div>
        <div style="clear:both"></div>
        <div id="sumPayment" runat="server" class="sum-total" style="width: 310px; float: right; font-weight: bold;font-size:13pt;"> </div>

       <div id="sumWeight" runat="server" class="sum-weight" style="display:none;">0</div>
        <div id="sumWeightSO" runat="server" class="sum-weight" style="display:none;">0</div>
       <div id="DivAmount" runat="server" style="display:none;">0</div>
        <div id="DivAmountAccumulate" runat="server" style="display:none;">0</div>
       <div id="DivSumPayment" runat="server" style="display:none;">0</div>
       <div id="DivConvertedAmount" runat="server" style="display:none;">0</div>
       <div id="DivDiscountAmount" runat="server" style="display:none;">0</div>
        <div id="DivDiscountPromotionID" runat="server" style="display:none;">0</div>
        <div id="DivDiscountPromotionDetailID" runat="server" style="display:none;">0</div>

       
    </ContentTemplate>
</asp:UpdatePanel>

<div class="progressbar">
    <asp:UpdateProgress ID="up" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
        <ProgressTemplate>
            <div class="bg">
                <div class="progress progress-striped active">
                    <div class="progress-bar" role="progressbar" aria-valuenow="45" aria-valuemin="0"
                        aria-valuemax="100" style="width: 100%">
                        <span class="sr-only">100% Complete</span>
                    </div>
                </div>
            </div>
        </ProgressTemplate>
    </asp:UpdateProgress>
</div>

<script type="text/javascript">

    function Validate() {
        var isValid = false;
        isValid = Page_ClientValidate('g1');
        if (isValid) {
            isValid = Page_ClientValidate('g2');
        }
        /*
        if (isValid) {
            isValid = Page_ClientValidate('g4');
        }
        */
        if (isValid == false) {
            fnOnUpdateValidators('g1');
            fnOnUpdateValidators('g2');
        }
        return isValid;
    }

    function ValidateDelivery() {
        var isValid = Page_ClientValidate('g4');
        fnOnUpdateValidators('g4');
        if (isValid == false) {
            AjaxPanelResponseMessage('Vui lòng nhập thông tin giao hàng ở tab Thông tin giao hàng', 'msgFailed');
        }
        return isValid;
    }
    function OnClientClose(oWnd, args) {
        var arg = args.get_argument();
        if (arg != null) {
            var objCustomerCode = "<%=txtCustomerCode.ClientID%>";
            $('#' + objCustomerCode).val(arg.CustomerCode);

            var objCustomerName = "<%=txtCustomerName.ClientID%>";
            $('#' + objCustomerName).val(arg.CustomerName);


            var objReceiptPerson = "<%=txtReceiptPerson.ClientID%>";
            $('#' + objReceiptPerson).val(arg.CustomerName);

            var objReceiptPhoneNumer = "<%=txtReceiptPhoneNumer.ClientID%>";
            $('#' + objReceiptPhoneNumer).val(arg.PhoneNumber);

            var objReceiptAdress = "<%=txtReceiptAdress.ClientID%>";
            $('#' + objReceiptAdress).val(arg.Address);
        }
    }
</script>
